/* Reset and base styles for iframe compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%);
    overflow: hidden;
    /* Responsive height - 450px for iframe, 90vh for full screen */
    height: 450px;
    width: 100%;
    position: relative;
}

/* Media query for full screen viewing */
@media screen and (min-height: 500px) {
    body {
        height: 90vh;
    }
}

/* Main game container with cognitive load optimization */
.game-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, rgba(255,255,255,0.1) 0%, transparent 70%);
}

/* Game header - compact design for limited vertical space */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 2px solid #4CAF50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-height: 50px;
    flex-shrink: 0;
}

/* Score display with visual hierarchy */
.score-display, .lives-display {
    font-size: 16px;
    font-weight: bold;
    color: #2E7D32;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

/* Question display - central focus for cognitive processing */
.question-display {
    background: #FFF9C4;
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid #FF9800;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.question-text {
    font-size: 20px;
    font-weight: bold;
    color: #E65100;
}

/* Game area - main interaction space */
.game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(to bottom, 
        rgba(135, 206, 235, 0.3) 0%, 
        rgba(152, 251, 152, 0.3) 100%);
}

/* Falling marbles - interactive elements with clear visual feedback */
.marble {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: transform 0.1s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    /* Touch-friendly size for mobile */
    min-width: 44px;
    min-height: 44px;
}

/* Marble color variations for visual distinction */
.marble.correct {
    background: linear-gradient(135deg, #4CAF50 0%, #81C784 100%);
    border: 3px solid #2E7D32;
}

.marble.incorrect {
    background: linear-gradient(135deg, #2196F3 0%, #64B5F6 100%);
    border: 3px solid #1565C0;
}

/* Hover and touch states for interaction feedback */
.marble:hover, .marble:active {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

/* Modified: Basket catcher - main interaction target positioned at the bottom */
.basket {
    position: absolute;
    bottom: 5px; /* Changed: Positioned closer to the bottom */
    left: 50%;
    transform: translateX(-50%);
    width: 90px; /* Changed: Made slightly wider for better catching */
    height: 50px; /* Changed: Made slightly shorter for basket appearance */
    background: linear-gradient(135deg, #8B4513 0%, #D2691E 50%, #CD853F 100%); /* Changed: Brown basket color */
    border: 3px solid #654321; /* Changed: Darker brown border */
    border-radius: 0 0 25px 25px; /* Changed: Rounded bottom for basket shape */
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    /* Touch-friendly size */
    min-width: 70px;
    min-height: 40px;
    /* Added: Basket-specific styling */
    overflow: visible;
}

/* Added: Basket rim for realistic appearance */
.basket-rim {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    height: 8px;
    background: linear-gradient(135deg, #654321 0%, #8B4513 100%);
    border-radius: 15px 15px 0 0;
    border: 2px solid #4A4A4A;
}

/* Added: Basket handles for realistic appearance */
.basket-handle-left, .basket-handle-right {
    position: absolute;
    top: 5px;
    width: 12px;
    height: 20px;
    background: #654321;
    border: 2px solid #4A4A4A;
    border-radius: 8px;
}

.basket-handle-left {
    left: -15px;
    transform: rotate(-15deg);
}

.basket-handle-right {
    right: -15px;
    transform: rotate(15deg);
}

/* Modified: Basket face for emotional feedback */
.basket-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px; /* Changed: Slightly smaller to fit basket */
    transition: all 0.3s ease;
    z-index: 10; /* Added: Ensure face appears above basket elements */
}

/* Modified: Basket interaction states */
.basket:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.basket.happy {
    animation: bounce 0.5s ease;
}

.basket.sad .basket-face {
    transform: translate(-50%, -50%) rotate(180deg);
}

/* Updated: Animation for basket bounce */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Legacy class names maintained for JavaScript compatibility */
.tin-can {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 50px;
    background: linear-gradient(135deg, #8B4513 0%, #D2691E 50%, #CD853F 100%);
    border: 3px solid #654321;
    border-radius: 0 0 25px 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    min-width: 70px;
    min-height: 40px;
    overflow: visible;
}

.can-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 10;
}

.tin-can:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.tin-can.happy {
    animation: bounce 0.5s ease;
}

.tin-can.sad .can-face {
    transform: translate(-50%, -50%) rotate(180deg);
}

/* Game controls - accessible button design */
.game-controls {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.9);
    border-top: 2px solid #4CAF50;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-height: 60px;
}

/* Button styles optimized for touch and mouse */
.start-btn, .pause-btn, .restart-btn {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    /* Touch-friendly minimum size */
    min-height: 44px;
    min-width: 80px;
}

.start-btn, .restart-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #81C784 100%);
    color: white;
}

.pause-btn {
    background: linear-gradient(135deg, #FF9800 0%, #FFB74D 100%);
    color: white;
}

.start-btn:hover, .restart-btn:hover {
    background: linear-gradient(135deg, #45a049 0%, #75c277 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.3);
}

.pause-btn:hover {
    background: linear-gradient(135deg, #f57c00 0%, #ffb74d 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.3);
}

/* Feedback message for immediate response */
.feedback-message {
    font-size: 14px;
    font-weight: bold;
    color: #2E7D32;
    text-align: center;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Game over screen */
.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-over-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    max-width: 90%;
}

.game-over-content h2 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 24px;
}

.game-over-content p {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
}

/* Animations for engagement */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes celebration {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Responsive design for mobile devices */
@media screen and (max-width: 480px) {
    .game-header {
        padding: 6px 10px;
        min-height: 45px;
    }
    
    .question-text {
        font-size: 18px;
    }
    
    .score-display, .lives-display {
        font-size: 14px;
    }
    
    .marble {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
    
    /* Modified: Responsive basket sizing */
    .basket, .tin-can {
        width: 80px;
        height: 45px;
    }
    
    .basket-face, .can-face {
        font-size: 18px;
    }
    
    .basket-handle-left, .basket-handle-right {
        width: 10px;
        height: 18px;
    }
}

/* Tooltip styles for accessibility */
[title] {
    position: relative;
}

/* Visual feedback for correct/incorrect answers */
.correct-feedback {
    animation: celebration 0.5s ease;
    color: #4CAF50;
}

.incorrect-feedback {
    color: #F44336;
}